package com.wmeimob.fastboot.jiubei.controller;

import com.github.pagehelper.PageInfo;
import com.wmeimob.fastboot.core.context.PageContext;
import com.wmeimob.fastboot.jiubei.entity.ShopOrders;
import com.wmeimob.fastboot.jiubei.service.ShopOrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjt
 * @version 1.0
 * @className ShopOrdersController
 * @description 【订单】控制器
 * @date Mon Aug 31 23:57:11 CST 2020
 **/
@RestController
@RequestMapping("shopOrders")
@Slf4j
public class ShopOrdersController {

    @Resource
    private ShopOrdersService shopOrdersService;


    /**
     * 订单分页查询
     *
     * @param shopOrders
     * @return
     */
    @GetMapping
    public PageInfo queryForShopOrders(ShopOrders shopOrders) {
        PageContext.startPage();
        return new PageInfo<ShopOrders>(shopOrdersService.findListByCondition(shopOrders));

    }

    /**
     * 订单导出
     *
     * @param shopOrders
     * @return
     */
    @PostMapping("/export")
    public List<ShopOrders> queryForShopOrdersExport(@RequestBody ShopOrders shopOrders) {
        return shopOrdersService.list(shopOrders);
    }


    /**
     * 订单查询-<通过id查询>
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ShopOrders queryForShopOrdersById(@PathVariable("id") Long id) {
        return shopOrdersService.queryShopOrdersById(id);
    }


    /**
     * 订单添加
     *
     * @param shopOrders
     * @return
     */
    @PostMapping
    public void insertForShopOrders(@RequestBody ShopOrders shopOrders) {
        shopOrdersService.addShopOrders(shopOrders);
    }


    /**
     * 订单修改
     *
     * @param shopOrders
     * @return
     */
    @PutMapping
    public void updateForShopOrders(@RequestBody ShopOrders shopOrders) {
        shopOrdersService.modifyShopOrders(shopOrders);
    }

    /**
     * 订单删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public void removeForShopOrders(@PathVariable("id") Long id) {
        shopOrdersService.removeShopOrders(id);
    }


}
